package com.godyao.dao;

import java.util.HashMap;
import java.util.Map;

public class UserDao {
    private static final Map<Integer, String> users = new HashMap();

//    static {
//        users.put(1, "张三");
//        users.put(2, "张四");
//        users.put(3, "李四");
//        users.put(4, "王五");
//    }
    public void initDataMethod() {
        System.out.println("执行：init-method初始化数据...");
        users.put(1, "张三");
        users.put(2, "张四");
        users.put(3, "李四");
        users.put(4, "王五");
    }

    public void destroyDataMethod() {
        System.out.println("执行：destroy-method");
        users.clear();
    }

//    private Map<Integer, String> users;

    public String getUserById(int id) {
        return users.get(id);
    }
}
